package com.stars.easyms.dubbo.filter;

import com.stars.easyms.base.util.ApplicationContextHolder;
import com.stars.easyms.dubbo.properties.EasyMsDubboProperties;
import org.apache.dubbo.rpc.Filter;

/**
 * <p>className: BaseEasyMsDubboFilter</p>
 * <p>description: 基础dubbo过滤器</p>
 *
 * @author guoguifang
 * @version 1.7.0
 * @date 2020/11/13 4:22 下午
 */
abstract class BaseEasyMsDubboFilter implements Filter, Filter.Listener {

    EasyMsDubboProperties easyMsDubboProperties;

    BaseEasyMsDubboFilter() {
        this.easyMsDubboProperties = ApplicationContextHolder.getApplicationContext().getBean(EasyMsDubboProperties.class);
    }

    private static final String[] DUBBO_INNER_SERVICE_NAMES = new String[]{
            "com.alibaba.cloud.dubbo.service.DubboMetadataService",
            "com.alibaba.dubbo.rpc.service.GenericService",
            "org.apache.dubbo.rpc.service.GenericService"
    };

    boolean isDubboInnerService(String serviceName) {
        for (String dubboInnerServiceName : DUBBO_INNER_SERVICE_NAMES) {
            if (dubboInnerServiceName.equals(serviceName)) {
                return true;
            }
        }
        return false;
    }

}
